<script type="text/javascript">
        function showAgentWindow(id)
        {
                window.open("/other_org/agent_info/"+id,"_blank","height=450,width=550,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
        }
function showProductWindow(id)
{
    window.open("/product/product_info/"+id,"_blank","height=500,width=750,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
function showPaperWindow(id)
{
    window.open("/sale/show_print_sale_paper/"+id,"_blank","height=450,width=700,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
</script>
<h1>报表中心 - <span id="secondHeading">产品销售</span></h1>
<%=form_tag({}, :id=>"input-form")%>
<TABLE border="0" id="INPUT_TABLE">
		<tr><td colspan="2">
			<% if @flash[:notice] -%>
					<div id="notice"><%= @flash[:notice] %></div>
				<% end -%>
			</td>
		</tr>
	<TR>
		<TD  align="center">品名规格&nbsp;&nbsp;<input type="text" name="serial" maxlength="20">&nbsp;&nbsp;导针规格&nbsp;&nbsp;<input type="text" name="name" maxlength="20"></TD>
		<TD><input type="submit" class="sub" value="查询"></TD>
	</TR>
</TABLE>
<%=end_form_tag%>
<%if @productList%>
</p>
<TABLE border="0" id="LIST_TB">
	<TR id="LIST_TB_TITLE">
		<TD>客户</TD>
                <TD colspan="2">产品</TD>
                <TD>订单号</TD> 
                <TD>发货单号</TD> 
                <TD>销售日期</TD> 
		<TD>提货数量（kpcs）</TD>
	</TR>
	<%@productList.each do |item|%>
	<TR id="LIST_TB_CONTENT1">
                <TD><a href="javascript:showAgentWindow(<%=item.id%>)"><%=item.name%></a></TD>
                <TD><a href="javascript:showProductWindow(<%=item.product.id%>)"><%=item.product.serial%></a></TD>
                <TD><a href="javascript:showProductWindow(<%=item.product.id%>)"><%=item.product.name%></a></TD>
                <TD><a href="javascript:showPaperWindow(<%=item.sale_paper_id%>)"><%=item.sale_paper_id%></a></TD>
                <TD><%=item.serialp%></TD>
                <TD><%=item.sale_date_at%></TD>
		<%retCount=0%>
		<%#retCount=@retHash[item.name].to_i if @retHash[item.name]%>
                <TD><%=item.count.to_f%><%#=item.count.to_i - retCount%></TD>
	</TR>
	<%end%>
	<TR id="LIST_TB_TITLE">
	   <TD colspan="7" align="right">总出货量:<%=0 if !@productTotal[0].count%><%=@productTotal[0].count%>,总退货量:<%=0 if !@retTotal[0].count%><%=@retTotal[0].count%>,净出货量:<%=@productTotal[0].count.to_f-@retTotal[0].count.to_f%></TD>
	</TR>
</TABLE>
<table>
        <tr>
                <td>
                        <input type="button" value="打印当前页" class="sub" onclick="openPrintWindow('LIST_TB')"/>
                        <input type="button" value="导出当前数据" class="sub" onclick="CellAreaExcel('LIST_TB')"/>
                </td>
        </tr>
</table>
<%end%>
